export default {
  methods: {
    // 设置表头
    getTableColumns (arr) {
      const tableColumns = {
        selection: {
          type: 'selection',
          width: 60,
          align: 'center',
          // fixed: 'left'
        },
        tNo: {
          title: '模板编号',
          minWidth: 100,
          align: 'center',
          key: 'tNo'
        },
        tName: {
          title: '模板名称',
          minWidth: 160,
          align: 'center',
          key: 'tName'
        },
        productType: {
          title: '销售产品类型',
          minWidth: 120,
          align: 'center',
          key: 'productType'
        },
        fileName: {
          title: '模板附件',
          minWidth: 100,
          align: 'center',
          slot: 'fileName'
        },
        createUser: {
          title: '创建人',
          minWidth: 100,
          align: 'center',
          key: 'createUser'
        },
        createTime: {
          title: '创建时间',
          minWidth: 180,
          align: 'center',
          render: (h, params) => {
            let row = params.row
            let times = row.createTime.slice(0, 19).replace(/T/g, ' ')
            return h('span', times)
          }
        },
        contractNo: {
          title: '合同编号',
          minWidth: 100,
          align: 'center',
          key: 'contractNo'
        },
        applyUserName: {
          title: '申请人',
          minWidth: 100,
          align: 'center',
          key: 'applyUserName'
        },
        applyDepartment: {
          title: '所属部门',
          minWidth: 100,
          align: 'center',
          key: 'applyDepartment'
        },
        applyTime: {
          title: '申请时间',
          minWidth: 120,
          align: 'center',
          render: (h, params) => {
            let row = params.row
            let times = row.applyTime.slice(0, 10)
            return h('span', times)
          }
        },
        contractType: {
          title: '合同类型',
          minWidth: 100,
          align: 'center',
          key: 'contractType'
        },
        sealType: {
          title: '印章类型',
          minWidth: 100,
          align: 'center',
          key: 'sealType'
        },
        contractTemplate: {
          title: '商务合同模板',
          minWidth: 120,
          align: 'center',
          key: 'contractTemplate'
        },
        process: {
          title: '审批进度',
          minWidth: 100,
          align: 'center',
          key: 'process'
        },
        action: {
          title: '操作',
          minWidth: 380,
          align: 'center',
          slot: 'action',
          // fixed: 'right'
        },
        action_2: {
          title: '操作',
          minWidth: 200,
          align: 'center',
          slot: 'action_2',
          // fixed: 'right'
        }
      }
      let data = []

      arr.forEach(col => data.push(tableColumns[col]))

      return data
    },
    downFile (id) {
      this.$emit('down-file', id)
    },
    downSelaFile (id) {
      this.$emit('down-selafile', id)
    }
  }
}
